package com.rightsidetech.http.controller.admin.system;

import com.github.pagehelper.PageInfo;
import com.rightsidetech.commom.base.PageRequest;
import com.rightsidetech.commom.base.ResponseData;
import com.rightsidetech.http.aspect.Auth;
import com.rightsidetech.http.aspect.Log;
import com.rightsidetech.http.aspect.Token;
import com.rightsidetech.system.dtos.request.SysSignRuleUpReq;
import com.rightsidetech.system.dtos.request.SysSignStatusReq;
import com.rightsidetech.system.dtos.response.SysSignRulePageResp;
import com.rightsidetech.system.service.SysRuleSignIntegralService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/admin/sys_rule")
@Api(tags = "签到积分规格相关")
@ShenyuSpringMvcClient(path = "/admin/sys_rule/**")
public class SysRuleSignIntegralController {

    @Resource
    private SysRuleSignIntegralService sysRuleSignIntegralService;


    @Log
    @Token
    @Auth(bizType = Auth.OPERATOR)
    @GetMapping("/page")
    @ApiOperation("分页查询签到积分")
    public ResponseData<PageInfo<SysSignRulePageResp>> page(PageRequest req){
         return sysRuleSignIntegralService.page(req);
    }


    @Log
    @Token
    @Auth(bizType = Auth.OPERATOR)
    @PostMapping("/update")
    @ApiOperation("修改积分规则")
    public ResponseData updateRule(@RequestBody SysSignRuleUpReq req){
        return sysRuleSignIntegralService.SysSignRuleUpReq(req);
    }

    @Log
    @Token
    @Auth(bizType = Auth.OPERATOR)
    @PostMapping("/open_close")
    @ApiOperation("开启关闭积分规则")
    public ResponseData isOpen(@RequestBody SysSignStatusReq req){
        return sysRuleSignIntegralService.upStatus(req);
    }
}
